class Inrex {
    constructor() {
        this.header = document.querySelector('#header');
        this.init();
    }
    init() {
        //记录this
        let that = this;
        //先获取免登录中cookie的用户名
        let cookie_str = cookie.get('logined'); //这是最后一次登录成功的用户名
        //检测用户名是否存在
        if (cookie_str) {
            this.header.innerHTML = `
                <span style = "color : #fff">欢迎：${cookie_str}</span> &nbsp&nbsp&nbsp&nbsp<a href="javascript:;" id="cls">退出</a>
            `
            //获取退出按钮
            let o_cls = document.querySelector('#cls');
            o_cls.onclick = function () {
                cookie.remove('logined', { path: '/' });
                that.init();
            }
        } else {
            this.header.innerHTML = `
                <a href="../../dist/html/login.html">登录</a>&nbsp&nbsp&nbsp&nbsp <a href="../../dist/html/signup.html">注册</a>
            `
        }
    }
}
new Inrex();